home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / Sample Code / Newton Sample Code 1.1 / Proto Templates / protoTable-2 / protoTable.text < prev    next >
Encoding:
Text File  |  1994-02-28  |  4.6 KB  |  168 lines  |  [TEXT/MPS ]

  1. // Copyright © 1993-94 Apple Computer, Inc. All rights reserved.
  2.  
  3. constant kAppSymbol := '|Table:PIEDTS|;
  4.  
  5. // ---- End Project Data ----
  6.  
  7.  
  8. // ---- File protoTable.t ----
  9. tableApp :=
  10.    {title: "protoTable example",
  11.     viewBounds: {top: 0, left: 0, right: 240, bottom: 336},
  12.     viewScrollUpScript:
  13.       func()
  14.       begin
  15.          theTable:viewScrollUpScript();
  16.       end,
  17.     viewScrollDownScript:
  18.       func()
  19.       begin
  20.          theTable:viewScrollDownScript();
  21.       end,
  22.     viewSetupFormScript:
  23.       func()
  24.       begin
  25.          local a := GetAppParams();
  26.          self.viewBounds := RelBounds(a.appAreaLeft, a.appAreaTop, a.appAreaWidth, a.appAreaHeight);
  27.       end,
  28.     _proto: protoApp,
  29.     debug: "tableApp"
  30.    };
  31.  
  32. theTable := /* child of tableApp */
  33.    {def: protoTableDef,
  34.     viewSetupFormScript:
  35.       func()
  36.       begin
  37.           // clone the table definition first to avoid read only errors
  38.           def := Clone(def);
  39.           def.tabProtos := protoTableEntry;    // protoTableEntry
  40.         
  41.         // For full-width text, the tabWidths MUST fit inside the table or nothing will appear,
  42.           // so this calculation accomplishes that.  It's bogus and redundant and you should, if at
  43.           // all possible, precalculate and put in a constant here.  The 2 at the end leaves space
  44.           // for the table border on either side.  (Sigh)
  45.           def.tabWidths := viewBounds.right - viewBounds.left - 2 ;
  46.           def.tabDown := 10;
  47.           def.tabValueSlot := 'text;
  48.           def.tabValues := ["foo", "bar", "baz", "qux", "4", "5", "6", "7", "8", "9"];
  49.       end,
  50.     viewBounds: {left: 10, top: 26, right: 201, bottom: 104},
  51.     scrollAmount: 1,
  52.     currentSelection: nil,
  53.     selectThisCell:
  54.       func(which)
  55.       begin
  56.          // skanky hack to get informed when cells are selected
  57.          // make sure to call the inherited function, otherwise things
  58.          // do not get updated properly!
  59.          inherited:selectThisCell(which);
  60.       
  61.          // currentSelection contains the item from the table
  62.          // definition tabValues array that is selected....
  63.          // so use that to set the text slot of theText 
  64.          SetValue(theText, 'text, currentSelection);
  65.       end,
  66.     debug: "theTable",
  67.     viewScrollDownScript:
  68.       func()
  69.       begin
  70.          local biggestTop;
  71.          local temp := ((viewBounds.bottom - viewBounds.top) / def.tabHeights);
  72.          temp := if (temp - Floor(temp)) < 0.5 then Floor(temp) else Floor(temp) + 1 ;
  73.       
  74.          // biggestTop is the cell index of the topmost cell when
  75.          // the table is maximally scrolled
  76.          biggestTop := Max(0, def.tabDown - temp) ;
  77.       
  78.          if vOrg < biggestTop then
  79.          begin
  80.             vOrg := vOrg + scrollAmount;
  81.             if vOrg > biggestTop then
  82.                vOrg := biggestTop ;
  83.        
  84.            tabbase:RedoChildren();
  85.             :updateSelection();
  86.          end;
  87.       end,
  88.     _proto: protoTable
  89.    };
  90. // View theTable is declared to tableApp
  91.  
  92.  
  93.  
  94. _view000 := /* child of tableApp */
  95.    {text: "You Picked:",
  96.     viewBounds: {left: 10, top: 114, right: 74, bottom: 138},
  97.     _proto: protoStaticText
  98.    };
  99.  
  100.  
  101.  
  102. theText := /* child of tableApp */
  103.    {text: "",
  104.     viewBounds: {left: 74, top: 114, right: 162, bottom: 130},
  105.     _proto: protoStaticText,
  106.     debug: "theText"
  107.    };
  108. // View theText is declared to tableApp
  109.  
  110.  
  111.  
  112. _view001 := /* child of tableApp */
  113.    {viewBounds: {left: 206, top: 41, right: 225, bottom: 64},
  114.     viewFormat: 1,
  115.     buttonPressedScript:
  116.       func()
  117.       begin
  118.          theTable:viewScrollUpScript();
  119.          theTable:Dirty();
  120.          RefreshViews();
  121.       end,
  122.     _proto: protoPictureButton
  123.    };
  124.  
  125. // After Script for "_view001"
  126. thisView := _view001;
  127. begin
  128.    // skanky hack to get ROM version of up arrow into
  129.    // the icon slot.
  130.    // see the Documentation (interrim or otherwise)
  131.    // for further explantion of afterScript and beforeScript
  132.    thisView.icon := ROM_uparrowbitmap ;
  133. end
  134.  
  135.  
  136.  
  137. _view002 := /* child of tableApp */
  138.    {viewBounds: {left: 206, top: 68, right: 225, bottom: 88},
  139.     viewFormat: 1,
  140.     buttonPressedScript:
  141.       func()
  142.       begin
  143.          theTable:viewScrollDownScript() ;
  144.          theTable:Dirty();
  145.          RefreshViews();
  146.       end,
  147.     _proto: protoPictureButton
  148.    };
  149.  
  150. // After Script for "_view002"
  151. thisView := _view002;
  152. begin
  153.    // skanky hack to get ROM version of up arrow into
  154.    // the icon slot.
  155.    // see the Documentation (interrim or otherwise)
  156.    // for further explantion of afterScript and beforeScript
  157.    thisView.icon := ROM_downarrowbitmap ;
  158. end
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166. // ---- Beginning of section for non used Layout files ----
  167.  
  168. // End of output